/**
 * Created by crazycooler on 2016/12/22.
 */

export function makeShortID(){
	let code = ["a", "b", "c", "d", "e", "f",
		"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
		"t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
		"6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
		"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
		"W", "X", "Y", "Z","_","-"];

	let timeMark = (new Date()).getTime();

	let timeMarkLow = timeMark & 0x00ffffff;
	let timeMarkHigh = (timeMark - timeMarkLow) / 0x1000000;

	let id = '';
	for(let i=0;i<4;i++){
		id = code[timeMarkLow & 63] + id;
		timeMarkLow /= 64;
	}

	for(let i=0;i<3;i++){
		id = code[timeMarkHigh & 63] + id;
		timeMarkHigh /= 64;
	}

	let ran = Math.floor(Math.random()*262144);
	for(let i=0;i<3;i++){
		id += code[ran & 63];
		ran >>= 6;
	}

	return id;
}
